package cn.edu.hqu.cst.android.ljc.test3;

import androidx.appcompat.app.AppCompatActivity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.widget.TextView;


public class ShowSystemInfo extends AppCompatActivity {

    TextView showInfo;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_system_info);

        showInfo = findViewById(R.id.show_sys_info);
        StringBuilder status = new StringBuilder();
        Configuration cfg = getResources().getConfiguration();
        //使用configuration对象获取系统属性
        String orientation = cfg.orientation == Configuration.ORIENTATION_LANDSCAPE ? "横向屏幕": "竖向屏幕";
        String touchscreen = cfg.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH ? "无触摸屏" : cfg.touchscreen == Configuration.TOUCHSCREEN_STYLUS ? "触摸笔式触摸屏" : "接收手指的触摸屏";
        String navigation = cfg.navigation == Configuration.NAVIGATION_NONAV ? "没有方向控制" : cfg.orientation == Configuration.NAVIGATION_WHEEL ? "滚轮控制方向" : cfg.orientation == Configuration.NAVIGATION_DPAD ? "方向键控制方向 ": "轨迹球控制方向";


        status.append("屏幕方向：" + orientation +  "\n");
        status.append("系统触摸屏的触摸方式：" + touchscreen + "\n");
        status.append("系统上方向导航设备的类型：" + navigation + "\n");

        showInfo.setText(status.toString());
    }
}